/**
 * @param {string} s
 * @return {string}
 */


var longestPalindrome = function (s) {
  //想办法取到各种模式串
  let len = s.length
  if (len == 1) return s
  for (let i = 1; i < len; i++) {
    for (let j = 0; j <= i; j++) {
      var par = s.substr(j, s.length - i)
      // console.log(par)
      for (let l = 0; l <= i; l++) {
        if (l == j) continue
        if (s.substr(l, s.length - i) == par) return par
        // else {console.log(s.substr(l, s.length - i)+ "----")}
      }
    }
  }
  return false
};


console.log(longestPalindrome("babad"))